package net.apexes.demo.codegen.dslite.qvar;

import net.apexes.demo.codegen.dslite.entity.GoodsFeature;
import net.apexes.demo.codegen.dslite.qvar.base.QEntityBase;
import net.wafo.dslite.core.info.ForeignKey;
import net.wafo.dslite.core.info.Index;

import net.wafo.dslite.core.dsl.*;

/**
 * QGoodsFeature is a DSLite query type for GoodsFeature
 * @see GoodsFeature
 */
public class QGoodsFeature extends QEntityBase<GoodsFeature> {

    public static final QGoodsFeature $ = new QGoodsFeature("GOODS_FEATURE");

    public final StringColumn goodsId = varchar("GOODS_ID", 22).field("goodsId").notNull().build();

    public final StringColumn goodsBaseId = varchar("GOODS_BASE_ID", 22).field("goodsBaseId").notNull().build();

    public final StringColumn featureId = varchar("FEATURE_ID", 22).field("featureId").notNull().build();

    public final StringColumn featureGroupId = varchar("FEATURE_GROUP_ID", 22).field("featureGroupId").notNull().build();

    public final StringColumn templateId = varchar("TEMPLATE_ID", 22).field("templateId").notNull().build();

    public class Indexs {

        public final Index constraintIndexE = index("CONSTRAINT_INDEX_E").unique().column(goodsId).column(featureId).build();

        public final Index constraintIndexEb = index("CONSTRAINT_INDEX_EB").column(featureId).build();

        public final Index constraintIndexEb6 = index("CONSTRAINT_INDEX_EB6").column(featureGroupId).build();

        public final Index constraintIndexEb6b = index("CONSTRAINT_INDEX_EB6B").column(goodsId).build();

        public final Index constraintIndexEb6bb = index("CONSTRAINT_INDEX_EB6BB").column(goodsBaseId).build();

        public final Index primaryKeyE = index("PRIMARY_KEY_E").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraintEb6 = foreignKey(featureId, "FEATURE", "ID");

        public final ForeignKey constraintEb6b = foreignKey(featureGroupId, "FEATURE_GROUP", "ID");

        public final ForeignKey constraintEb6bb = foreignKey(goodsId, "GOODS", "ID");

        public final ForeignKey constraintEb6bb6 = foreignKey(goodsBaseId, "GOODS_BASE", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QGoodsFeature(String tableName) {
        super(GoodsFeature.class, tableName);
    }

    @Override
    public GoodsFeature newEntity() {
        return new GoodsFeature();
    }

    @Override
    public Object getFieldValue(GoodsFeature entity, String fieldName) {
        switch (fieldName) {
            case "goodsId":
                return entity.getGoodsId();
            case "goodsBaseId":
                return entity.getGoodsBaseId();
            case "featureId":
                return entity.getFeatureId();
            case "featureGroupId":
                return entity.getFeatureGroupId();
            case "templateId":
                return entity.getTemplateId();
            default:
                return super.getFieldValue(entity, fieldName);
        }
    }

    @Override
    public void setFieldValue(GoodsFeature entity, String fieldName, Object value) {
        switch (fieldName) {
            case "goodsId":
                entity.setGoodsId((java.lang.String) value);
                break;
            case "goodsBaseId":
                entity.setGoodsBaseId((java.lang.String) value);
                break;
            case "featureId":
                entity.setFeatureId((java.lang.String) value);
                break;
            case "featureGroupId":
                entity.setFeatureGroupId((java.lang.String) value);
                break;
            case "templateId":
                entity.setTemplateId((java.lang.String) value);
                break;
            default:
                super.setFieldValue(entity, fieldName, value);
                break;
        }
    }

}

